<!DOCTYPE html>
<html>
<head>
    <title>攻略系列</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css"/>
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategyCatalogs.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css"/>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <script src="/js/plugins/ckeditor/ckeditor.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/plugins/dialog/dialog.min.js"></script>


</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col-2">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">
            <div class="input-group-sm search">
                <input class="form-control searchBtn" placeholder="搜索旅行攻略">
            </div>
        </div>
    </div>
</div>

<div class="container strategies">
    <h5 class="title" render-html="title">广州攻略</h5>
    <small><span>0</span>人阅读过此游记</small>
    <div class="focus">
        <i class="fa fa-heart"><span> 0</span> 收藏</i>
        <i class="fa fa-thumbs-up"><span> 0</span> 点赞</i>
        <button class="btn">想去</button>
        <button class="btn">去过</button>
        <div class="col-7 comment-head" >
            <a href="userProfiles.html">
                <img class="rounded-circle col-5" render-src="author.headImgUrl">
                <p class="authorName" ><span render-html="author.nickName"></span></p>
                <div     render-html="createTime"></div>
                <img render-src="coverUrl" >
            </a>
        </div>
    </div>
</div>






<hr>

<div id="comment">

    <div render-loop="list">
        <div class="container row comment ">
            <div class="col-2 comment-head" >
                <a href="userProfiles.html">

                    <img class="rounded-circle" render-src="list.user.headImgUrl">

                </a>
            </div>


            <div class="col comment-right">

                <p class="authorName" ><span render-html="list.user.nickName"></span></p>
                <span class="comment-star" render-fun="star" render-key="list.id" >
                            <!--动态回显星星的地方-->
                        </span>


                <span class="comment-date" render-html="list.createTime"></span>

                <div class="comment-content">
                    <a render-fun="hand" render-key="list.id" render-html="list.comment">jqueryRatingStars
                        <p></p>
                    </a>
                </div>


                <ul class="comment-img">
                    <li>
                                <span>
                                <img render-src="list.coverUrl">
                                 </span>
                    </li>
                </ul>
                <input name="id" type="hidden" id="id">

                <div class="d-flex icon">


                    <a render-fun="hand" render-key="list.id" >
                        <i class="fa  fa-commenting-o " style="margin-right: 10px"> 评论 </i>
                    </a>

                    <!--<a render-fun="handup" render-key="list.id" >
                        <i class="fa  fa-commenting-o " style="margin-right: 10px"> 编辑 </i>
                    </a>-->

                    <!--<a id="btnlike" onclick="getLike()" render-fun="like" render-key="list.id">
                        <i class="fa fa-thumbs-o-up" id="like"> <span>0</span> </i>
                    </a>-->

                </div>

            </div>

        </div>

    </div>
</div>


<div class="operation">
    <button class="btn">加入旅行单</button>
    <button class="btn" id="commentBtn">点评</button>
</div>




<script>
    $(function () {

        var id = getParams().id;
        var currentPage = 1;
        var pages;
        var comment;
        $.get("/travels/"+id,{"purpose":1},function (data) {
            console.log(data);
            $(".strategies").renderValues(data);

        })


        $("#commentBtn").click(function () {
            window.location.href = "traveladdComment.html?travelId=" + id;
        })

        //回显点评
        $.get("/travels/comment/" + id, function (data) {
            pages = data.pages;
            comment=data.list;
            console.log(data);
            $("#comment").renderValues(data, {
                star: function (ev, val) {
                    $(ev).attr("id", "star" + val);
                    console.log(ev);
                },
                hand:function (ele, value) {
                    ele.href="/travelComment.html?id="+value;
                },
                handup:function (ele, value) {
                    ele.href="traveladdComment.html?travelId="+value;
                },
                like:function (ele, value) {

                }
            });
            $.each(data.list,function (index, ele) {
                creatStart(ele.state * 2,ele.id)

            })
        })




        //回显点评五角星的函数
        function creatStart(count,id) {
            var star = $("  <i class=\"fa fa-star-o\"></i>\n" +
                "                            <i class=\"fa fa-star-o\"></i>\n" +
                "                            <i class=\"fa fa-star-o\"></i>\n" +
                "                            <i class=\"fa fa-star-o\"></i>\n" +
                "                            <i class=\"fa fa-star-o\"></i>");
            for (var i = 0; i < count; i++) {
                console.log(star[i]);
                var s = star[i];
                $(s).removeClass("fa-star-o")
                $(s).addClass("fa fa-star");
            }
            $(star).appendTo("#star"+id+"");
        }

        $(window).scroll(function () {
            if (isFull()) {
                if (currentPage < pages) {
                    $.get("/travels/comment/"+id, {currentPage: ++currentPage}, function (data) {
                        $.merge(comment, data.list);
                        console.log(comment);


                        $("#comment").renderValues({list: comment}, {
                            star: function (ev, val) {
                                $(ev).attr("id", "star" + val);
                                console.log(ev);
                            },
                            hand:function (ele, value) {
                                ele.href="/travelComment.html?id="+value;
                            },
                            handup:function (ele, value) {
                                ele.href="traveladdComment.html?travelId="+value;
                            }
                        });
                        $.each({list: comment}.list,function (index, ele) {
                            creatStart(ele.state * 2,ele.id)

                        })

                    })
                } else {
                    $(document).dialog({
                        type: "notice",
                        infoText: "到底部了",
                        autoClose: 2500,
                        position: "bottom"  // center: 居中; bottom: 底部
                    });
                }
            }
        })



    })

    function getLike() {
        console.log(5555);

        console.log($("#like").data(id));
        var likestpye=$("#like").attr("class")
        if ( likestpye == "fa fa-thumbs-o-up"){
            $("#like").attr("class","fa fa-thumbs-up")


        }

        if (likestpye == "fa fa-thumbs-up"){
            $("#like").attr("class","fa fa-thumbs-o-up")
        }

    }
</script>


</body>
</html>